#ifndef __CLIENT_SYS_H
#define __CLIENT_SYS_H

#pragma once

class ClientSys
{
public:
	ClientSys();
	virtual ~ClientSys();

	struct timeval CalcDiffTime( timeval begin, timeval end)
	{
		struct timeval difference;
		difference.tv_sec  = end.tv_sec  - begin.tv_sec;
		difference.tv_usec = end.tv_usec - begin.tv_usec;

		// Perform the carry for the later subtraction by updating end
		if (begin.tv_usec < end.tv_usec) {
			int nsec = (end.tv_usec - begin.tv_usec) / 1000000 + 1;
			end.tv_usec -= 1000000 * nsec;
			end.tv_sec  += nsec;
		}
		if (begin.tv_usec - end.tv_usec > 1000000) {
			int nsec = (end.tv_usec - begin.tv_usec) / 1000000;
			end.tv_usec += 1000000 * nsec;
			end.tv_sec  -= nsec;
		}

		difference.tv_sec  = end.tv_sec  - begin.tv_sec ;
		difference.tv_usec = end.tv_usec - begin.tv_usec;

		while (difference.tv_usec < 0) {
			difference.tv_usec += 1000000;
			difference.tv_sec  -= 1;
		}

		return (difference);
	}
};

#endif
